// 路由相关工具函数

import { IGetUserMenusResponse } from '@/service/api/user/types'
import { RouteRecordRaw } from 'vue-router'

// 处理接口返回的路由，为component提供动态加载
export function solveRoutesComponent(list: IGetUserMenusResponse['list']): RouteRecordRaw[] {
  return list.map((item) => {
    return {
      ...item,
      component: () => import(item.component),
      children: solveRoutesComponent(item.children || []),
    }
  })
}
